package com.wugh.fast.demo.controller;

import com.wugh.fast.demo.entity.Entity1;
import com.wugh.fast.demo.service.CacheService;
import com.wugh.fast.kernel.util.CopyUtils;
import com.wugh.fast.module.api.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 说明:
 *
 * @author wugh
 * @date 2019-07-24 16:59
 */
@RestController
@RequestMapping("/api/cache")
public class CacheController {
    @Autowired
    private CacheService cacheService;


    @GetMapping("{key}")
    public ResponseVO<Entity1> get(@PathVariable String key){
        Entity1 data = cacheService.get(key);
        return ResponseVO.ok(CopyUtils.copyObject(data,Entity1.class));
    }
    @DeleteMapping("{key}")
    public ResponseVO<Entity1> delete(@PathVariable String key){
        return ResponseVO.ok(cacheService.delete(key));
    }
}
